﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models.world.vos.actors {
    import flash.events.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;

    public class AvatarVO extends AbstractActorVO implements IAvatar {

        private var _actions:Array;
        private var _currentAction:InfoEvent;
        private var _targetX:Number;

        public function AvatarVO(_arg1:Object, _arg2:IEventDispatcher){
            this._actions = [];
            super(_arg1, _arg2);
            _moveCommandType = EventConstants.MOVE_TO_ROOM;
        }
        public function set currentAction(_arg1:InfoEvent):void{
            this._currentAction = _arg1;
        }
        public function get currentAction():InfoEvent{
            return (this._currentAction);
        }
        public function get targetX():Number{
            return (this._targetX);
        }
        public function addAction(_arg1:String, _arg2:InfoEvent):void{
            var _local3:RoomActionVO = new RoomActionVO(_arg1, _arg2);
            this._actions.push(_local3);
        }
        public function gotoNextRoom():void{
            if (this.nextTargetRoomId){
                this.moveToRoom(this.nextTargetRoomId);
            } else {
                this._currentAction = null;
            };
        }
        public function moveToRoom(_arg1:String, _arg2:Number=0):void{
            targetRoomId = _arg1;
            this._targetX = _arg2;
            if (!isMoving){
                dispatch(new InfoEvent(EventConstants.MOVE_TO_ROOM, null, this));
            };
        }
        public function handleNextAction():void{
            this._currentAction = null;
            if (this._actions.length){
                this._currentAction = this.nextAction;
                this._actions.shift();
                dispatch(this._currentAction);
            };
        }
        private function get nextRoomAction():RoomActionVO{
            if (((this._actions) && (this._actions.length))){
                return ((this._actions[0] as RoomActionVO));
            };
            return (null);
        }
        private function get nextTargetRoomId():String{
            return ((this.nextRoomAction) ? this.nextRoomAction.roomId : null);
        }
        private function get nextAction():InfoEvent{
            return ((this.nextRoomAction) ? this.nextRoomAction.action : null);
        }

    }
}//package net.wooga.pets.models.world.vos.actors 

import net.wooga.pets.events.*;

class RoomActionVO {

    private var _roomId:String;
    private var _action:InfoEvent;

    public function RoomActionVO(_arg1:String, _arg2:InfoEvent){
        this._roomId = _arg1;
        this._action = _arg2;
    }
    public function get roomId():String{
        return (this._roomId);
    }
    public function get action():InfoEvent{
        return (this._action);
    }

}
